import { useDrawer } from '/@/components/Drawer';

export const useExtendDrawer = (reload, { deleteApi }) => {
  const [registerDrawer, { openDrawer }] = useDrawer();

  const handleCreate = () => {
    openDrawer(true, { isUpdate: false });
  };

  const handleUpdate = (record) => {
    openDrawer(true, { record, isUpdate: true });
  };

  const handleDelete = (id) => {
    deleteApi(id, reload);
  };

  return {
    registerDrawer,
    handleCreate,
    handleUpdate,
    handleDelete,
  };
};
